-
Couldn't load subscription status.
- Fork 13.9k
Reduce integer Display implementation size
#133247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce integer Display implementation size
#133247
Conversation
|
Thanks! r=me with squash. |
75f1ff7 to
a991f25
Compare
|
@bors r=workingjubilee |
|
@bors r- |
81d470f to
ab38c6d
Compare
|
@bors r=workingjubilee |
|
? PR CI doesn't run library tests...? |
|
@bors r- |
| #[cfg(feature = "optimize_for_size")] | ||
| fn $gen_name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| // 2^128 is about 3*10^38, so 39 gives an extra byte of space | ||
| let mut buf = [MaybeUninit::<u8>::uninit(); 39]; | ||
| const SIZE: usize = $u::MAX.ilog(10) as usize + 1; | ||
| let mut buf = [MaybeUninit::<u8>::uninit(); SIZE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? What is the effect of this change on binary size? Or is $u always the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On smaller targets, the maximum size might be of u32 and not u64 so since we're there... But on the binary size, there should be no difference for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, hopefully so.
|
The problem was indeed because I never tested with the |
|
Forgot to re-r+ it... @bors r=workingjubilee |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (7db7489): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary 0.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary -0.0%, secondary -0.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 797.447s -> 796.592s (-0.11%) |
I was thinking about #128204 and how we could reduce the size of the code and just realized that we didn't need the
_fmtmethod to be implemented on signed integers, which in turns allow to simplify greatly the macro call.r? @workingjubilee